<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								订单单号：<input type="text" name="orderNo"/>
							</li>

							<li>
								商店编号：<input type="text" name="shopId"/>
							</li>

							<li>
								订单状态:
								<select name="orderStatus" id="orderStatus" th:with="type=${@dict.getType('weChat_order_status')}">
								  <option value="">所有</option>
								  <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}">
								  </option>
								</select>
							</li>

							<li>
								订单支付渠道：<input type="text" name="payChannel"/>
							</li>

							<li>
								客户编号：<input type="text" name="userId"/>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm hidden-xs" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="wechat:wechatOrder:add">
					<i class="fa fa-plus"></i> 添加
				</a>
	       
				<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="wechat:wechatOrder:edit">
					<i class="fa fa-edit"></i> 修改
				</a>
				<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="wechat:wechatOrder:remove">
					<i class="fa fa-remove"></i> 删除
				</a>
				<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="wechat:wechatOrder:export">
						<i class="fa fa-download"></i> 导出
				 </a>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
    	var editFlag = [[${@permission.hasPermi('wechat:wechatOrder:edit')}]];
    	var removeFlag = [[${@permission.hasPermi('wechat:wechatOrder:remove')}]];
        var prefix = ctx + "wechat/wechatOrder";
        var weChat_order_status = [[${@dict.getType('weChat_order_status')}]];
        var weChat_pay_status = [[${@dict.getType('weChat_pay_status')}]];
        
        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                setSendGoodUrl: prefix + "/sendGood/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
                modalName: "订单管理",
		        showExport: true,
		        //fixedColumns: true,
    		    //fixedNumber: 8, 
                columns: [{
		            checkbox: true
		        },
				{
					field : 'orderId', 
					title : '自动编号',
					visible: false
				},
				{
					field : 'weixinUser.nickname', 
					title : '客户昵称',
					sortable: true
				},
				{
					field : 'orderNo', 
					title : '订单单号',
					sortable: true,
				 	formatter: function(value, row, index) {
				 		var actions = [];
				 		actions.push("<a href='#' onclick='orderDetail(\"" + row.orderId + "\")'>"+value+"</a>");
				 		return actions.join('');
				  	}
				},
				
				{
					field : 'orderStatus', 
					title : '订单状态',
					sortable: true,
				 	formatter: function(value, row, index) {
				      return $.table.selectDictLabel(weChat_order_status, value);
				  	}
				},
				{
					field : 'payStatus', 
					title : '支付状态',
					sortable: true,
				 	formatter: function(value, row, index) {
				      return $.table.selectDictLabel(weChat_pay_status, value);
				  	}
				},
				{
					field : 'productCount', 
					title : '商品数量',
					sortable: true
				},
				{
					field : 'productAmountTotal', 
					title : '商品总价',
					sortable: true
				},
				{
					field : 'logisticsFee', 
					title : '实付金额',
					sortable: true
				},
				{
					field : 'payChannel', 
					title : '支付渠道',
					sortable: true
				},
				{
					field : 'escrowTradeNo', 
					title : '支付订单号',
					sortable: true
				},
				{
					field : 'payTime', 
					title : '付款时间',
					sortable: true
				},
				{
					field : 'orderlogisticsId', 
					title : '订单物流编号',
					sortable: true
				},
				{
					field : 'deliveryTime', 
					title : '发货时间',
					sortable: true
				},
				
				{
					field : 'addressId', 
					title : '收货地址编号',
					sortable: true
				},
				
				{
					field : 'userRemark', 
					title : '客户备注',
					sortable: true
				},
				{
					field : 'createTime', 
					title : '创建时间',
					sortable: true
				},
				
				{
					field : 'updateTime', 
					title : '更新时间',
					sortable: true
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	if(row.orderStatus == 0){
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.orderId + '\')"><i class="fa fa-edit"></i>修改金额</a>&nbsp;');
		            	}else if(row.orderStatus == 1){
		            		actions.push('<a class="btn btn-success btn-xs  href="#" onclick="$.operate.sendGood(\'' + row.orderId + '\')"><i class="fa fa-edit"></i>订单发货</a>&nbsp;');
		            	}
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.orderId + '\')"><i class="fa fa-remove"></i>删除订单</a>');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });
        
        
        function orderDetail(orderId){
        	
        	$.modal.openNoBtn("订单明细", prefix + "/orderDetail/"+orderId);
        }
    </script>
</body>
</html>